<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."brand`");
$db->exe("CREATE TABLE `".$db_prefix."brand`".$db_prefix." (
  `".$db_prefix."bid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."bname`".$db_prefix." char(45) NOT NULL DEFAULT '' COMMENT '名称',
  `".$db_prefix."logo`".$db_prefix." varchar(80) NOT NULL DEFAULT '',
  `".$db_prefix."sort`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '100' COMMENT '排序',
  `".$db_prefix."is_hot`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否热门',
  PRIMARY KEY (`".$db_prefix."bid`".$db_prefix."),
  UNIQUE KEY `".$db_prefix."bname_UNIQUE`".$db_prefix." (`".$db_prefix."bname`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='品牌表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."category`");
$db->exe("CREATE TABLE `".$db_prefix."category`".$db_prefix." (
  `".$db_prefix."cid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."cname`".$db_prefix." char(15) NOT NULL DEFAULT '' COMMENT '名称',
  `".$db_prefix."pid`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
  `".$db_prefix."type_idtype`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."cid`".$db_prefix."),
  KEY `".$db_prefix."fk_category_type_idx`".$db_prefix." (`".$db_prefix."type_idtype`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='分类表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."detail`");
$db->exe("CREATE TABLE `".$db_prefix."detail`".$db_prefix." (
  `".$db_prefix."small`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '小图图册地址',
  `".$db_prefix."medium`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '中图图册地址',
  `".$db_prefix."big`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '大图图册地址',
  `".$db_prefix."intro`".$db_prefix." text COMMENT '商品详情',
  `".$db_prefix."service`".$db_prefix." text COMMENT '售后服务',
  `".$db_prefix."goods_gid`".$db_prefix." int(10) unsigned NOT NULL,
  KEY `".$db_prefix."fk_detail_goods1_idx`".$db_prefix." (`".$db_prefix."goods_gid`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='商品详细信息表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods`");
$db->exe("CREATE TABLE `".$db_prefix."goods`".$db_prefix." (
  `".$db_prefix."gid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."gname`".$db_prefix." char(45) NOT NULL DEFAULT '' COMMENT '商品名称',
  `".$db_prefix."gnumber`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '商品货号',
  `".$db_prefix."unit`".$db_prefix." char(5) NOT NULL DEFAULT '' COMMENT '计件单位',
  `".$db_prefix."marketprice`".$db_prefix." decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT '市场价',
  `".$db_prefix."shopprice`".$db_prefix." decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT '商城价',
  `".$db_prefix."pic`".$db_prefix." varchar(300) NOT NULL DEFAULT '' COMMENT '列表图地址',
  `".$db_prefix."click`".$db_prefix." smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
  `".$db_prefix."time`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上架时间',
  `".$db_prefix."category_idcategory`".$db_prefix." int(10) unsigned NOT NULL,
  `".$db_prefix."brand_bid`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."gid`".$db_prefix."),
  UNIQUE KEY `".$db_prefix."coname_UNIQUE`".$db_prefix." (`".$db_prefix."gname`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_category1_idx`".$db_prefix." (`".$db_prefix."category_idcategory`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_brand1_idx`".$db_prefix." (`".$db_prefix."brand_bid`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='商品表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_attr`");
$db->exe("CREATE TABLE `".$db_prefix."goods_attr`".$db_prefix." (
  `".$db_prefix."gtid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."gtvalue`".$db_prefix." char(15) NOT NULL DEFAULT '' COMMENT '商品属性的值',
  `".$db_prefix."added`".$db_prefix." decimal(10,0) NOT NULL,
  `".$db_prefix."goods_gid`".$db_prefix." int(10) unsigned NOT NULL,
  `".$db_prefix."type_attr_idtype_attr`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."gtid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_attr_goods1_idx`".$db_prefix." (`".$db_prefix."goods_gid`".$db_prefix."),
  KEY `".$db_prefix."fk_goods_attr_type_attr1_idx`".$db_prefix." (`".$db_prefix."type_attr_idtype_attr`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='商品属性表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."type`");
$db->exe("CREATE TABLE `".$db_prefix."type`".$db_prefix." (
  `".$db_prefix."idtype`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."typename`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '类型',
  PRIMARY KEY (`".$db_prefix."idtype`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='类型表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."type_attr`");
$db->exe("CREATE TABLE `".$db_prefix."type_attr`".$db_prefix." (
  `".$db_prefix."idtype_attr`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."name`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '属性名称',
  `".$db_prefix."type_value`".$db_prefix." varchar(225) NOT NULL DEFAULT '' COMMENT '属性值',
  `".$db_prefix."class`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '属性类型',
  `".$db_prefix."type_idtype`".$db_prefix." int(10) unsigned NOT NULL,
  PRIMARY KEY (`".$db_prefix."idtype_attr`".$db_prefix."),
  KEY `".$db_prefix."fk_type_attr_type1_idx`".$db_prefix." (`".$db_prefix."type_idtype`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='类型属性表'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user`".$db_prefix." (
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."username`".$db_prefix." char(45) NOT NULL DEFAULT '' COMMENT '用户名',
  `".$db_prefix."password`".$db_prefix." char(32) NOT NULL DEFAULT '' COMMENT '密码',
  `".$db_prefix."is_admin`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否为后台用户',
  `".$db_prefix."address`".$db_prefix." varchar(100) NOT NULL DEFAULT '' COMMENT '地址',
  `".$db_prefix."sex`".$db_prefix." enum('男','女') NOT NULL DEFAULT '男' COMMENT '性别',
  `".$db_prefix."is_lock`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '锁定',
  PRIMARY KEY (`".$db_prefix."uid`".$db_prefix."),
  UNIQUE KEY `".$db_prefix."username_UNIQUE`".$db_prefix." (`".$db_prefix."username`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户表'");
